/*
 *  hyperelastic.h
 *  EPPI-0.0
 *
 *  Created by Sergio Conde Martin on 1/04/11.
 *
 */
 
#ifndef _viscoelastic_h_
#define _viscoelastic_h_

#include <iostream>
#include <sstream>
#include "MATERIALS/material.h"

using namespace std;

class Viscoelastic : public Material
{
public:
	Material *matHyper;
	int nTau; 		//Number of internal variable
	vector < double > vTau; //Vector of relaxation (or retardation) time, , as many as number of internal variables.
	vector < double > vBeta;//Vector of strain-energy factor, as many as number of internal variables.
	VectorXd vMu;
	VectorXd vEta;
	int mode;
        int rheological;        //Is Viscoelasticity rheological?
        VectorXd I;
	
	//*** Consistent Integration ***
	double W;
	VectorXd S;
	MatrixXd Tv; // Free energy function second derivative respect to the ineternal variable (Similar concept than Ct)
	
public:
	Viscoelastic();
	Viscoelastic(ifstream &, const string &, const string &,  Material*);
	~Viscoelastic(){}
	
	/** Virtual functions from base */
	VectorXd getS(const VectorXd & );	// Provides the hyperelastic Second Piola-Kirchoff Stress Tensor
	VectorXd getS_Vol(const VectorXd & );	// Provides the hyperelactic volumetric part of the Second Piola-Kirchoff Stress Tensor
	VectorXd getS_Iso(const VectorXd & );	// Provides the hyperelactic isocoric part of the Second Piola-Kirchoff Stress Tensor
	void calcCt(const VectorXd & );
	double getJ(const VectorXd & );	// Volume ratio J for a given Caucht-Green Tensor C
	
	double getW(const VectorXd &, const MatrixXd & );
	VectorXd getS( const VectorXd &, const MatrixXd & );	// Provides the viscoelastic Second Piola-Kirchoff Stress Tensor
	VectorXd getQv(int, const VectorXd &, const MatrixXd & );	// Provides the Non-Equilibrium Stress
	MatrixXd getTv(int, const VectorXd &, const MatrixXd &);	// Provided the Non-Equilibrum viscoelastic tensor.
	
	VectorXd getS_Vol(const VectorXd &, const MatrixXd & );	// Provides the volumetric part of the Second Piola-Kirchoff Stress Tensor
	VectorXd getS_Iso(const VectorXd &, const MatrixXd & );	// Provides the isocoric part of the Second Piola-Kirchoff Stress Tensor
	
	int getNInternalVariable();
	int getMode();
        int getRheological();
	double getE();
	double getNu();
	double getLambda();
	double getMu();
	double getDensity();
	
	VectorXd getTau();
	VectorXd getBeta();
	VectorXd getEta();
        VectorXd getVMu();
	
	/**Local Function */
};

#endif	
	